import request from './https';
// const host = 'https://huanglx-qinghe.f.wmeimob.com';
const host = 'https://wx.tsingho.cn';
// 授权登录
export const apiWechatAuthMini = params =>
  request.get(`${host}/wechat/auth/wx-token`, params);
/** 获取用户信息 */
export const info = () => request.get(`${host}/wechat/wechatUser/info`);
/** 获取我的收货地址 */
export const userAddress = () => request.get(`${host}/wechat/user-address`);
/** 发送验证码 */
export const sendSms = params =>
  request.get(`${host}/wechat/wechatUser/sendSms`, params);
/** 注册 */
export const register = params =>
  request.get(`${host}/wechat/wechatUser/register`, params);
// 获取凭证
export const apiGetOssPlicy = params =>
  request.get(`${host}/wechat/aliyun/oss-token`, params);

/** --------------------------------首页---------------------------------- */
// 首页banner
export const bannerList = () => request.get(`${host}/wechat/indexBanner/list`);

// 首页产品分类
export const productClassify = () => request.get(`${host}/wechat/productClassify/index`);

// 所有产品分类
export const allProductClassify = () => request.get(`${host}/wechat/productClassify/list`);

// 首页banner详情
export const bannerDetail = id =>
  request.get(`${host}/wechat/indexBanner/${id}`);

// 首页所有资讯列表信息
export const indexInfo = params =>
  request.get(`${host}/wechat/qingheInfo/list`, params);

// 首页所有资讯详情
export const newsDetail = id => request.get(`${host}/wechat/qingheInfo/${id}`);

// 首页活动列表信息
export const activeList = params =>
  request.get(`${host}/wechat/activity/list`, params);

// 首页活动详情
export const activeDetail = id => request.get(`${host}/wechat/activity/${id}`);

// 首页参加活动报名
export const partIn = (id, params) => request.get(`${host}/wechat/activity/partIn/${id}`, params);

// 添加修改商品到购物车
export const editGoodsCar = params => request.post(`${host}/wechat/shopCart`, params);

// 删除购物车商品
let token = wx.getStorageSync('token');

export const apiCarDelete = data =>
  //   request.delete(`${host}/wechat/shopCart/${data}`, { data });
  wx.request({
    url: `${host}/wechat/shopCart`,
    method: 'DELETE',
    header: {
      Authorization: token
    },
    data: data
  });

/** --------------------------------我的---------------------------------- */
// 我的活动myActivity
export const myActive = params => request.get(`${host}/wechat/activity/myActivity`, params);

// 实名认证（用户提交实名信息）
export const submitCustomer = params => request.post(`${host}/wechat/real/customer`, params);

// 实名认证详情 (回显实名认证信息)
export const showCustomer = () => request.get(`${host}/wechat/real/info`);

/** 客服电话 */
export const companyInfo = () => request.get(`${host}/wechat/wechatUser/companyInfo`);

/** --------------------------------收货地址---------------------------------- */
// 获取我的收货地址列表
export const getAddress = () => request.get(`${host}/wechat/user-address`);

// 添加我的收货地址
export const addAddress = params =>
  request.post(`${host}/wechat/user-address`, JSON.stringify(params), {
    headers: {
      'Content-Type': 'application/json'
    }
  });

// wechat/user-address 修改我的收货地址
export const defineAddress = params => request.put(`${host}/wechat/user-address`, params);

// wechat/user-address/{id} 删除我的收货地址
export const deleteAddress = params => request.delete(`${host}/wechat/user-address/${params.id}`);

// 设置默认收货地址
export const getDefault = params => request.put(`${host}/wechat/user-address/default`, params);

/** 获取我的默认收货地址 */
export const addressDefault = () => request.get(`${host}/wechat/user-address/default`);

/** -------------------------- 商城首页 ---------------------------------- */
// 获取并设置banner
export const getBanner = () => request.get(`${host}/wechat/mallBanner`);

// 获取并设置banner详情
export const getBannerDetails = params => request.get(`${host}/wechat/mallBanner/${params.id}`);

// 获取全部分类
export const getAllClassify = () => request.get(`${host}/wechat/classify/all`);

// 获取热门商品
export const getPopularDetails = params => request.get(`${host}/wechat/goods`, params);

/** 查询商品详情 */
export const queryGoddsDetails = params => request.get(`${host}/wechat/goods/${params.id}`);

// 订单详情
export const orderDetail = params => request.get(`${host}/wechat/order/${params.id}`);

// wechat/common/rich-text/{id} 查询富文本
export const getRichText = params => request.get(`${host}/wechat/common/rich-text/${params.id}`);

// 查询商品
export const queryGoods = params => request.get(`${host}/wechat/goods`, params);

// 提交订单
export const commitOrder = params => request.post(`${host}/wechat/order`, params);
/** 物流查询 */
export const logisticsOrder = id => request.get(`${host}/wechat/order/logistics`, id);

// 取消支付订单
export const noOrder = params => request.post(`${host}/wechat/order/toPay`, params);

/** ---------------------------- 我的订单部分 ---------------------------------- */
// 查询订单
export const queryOrder = params => request.get(`${host}/wechat/order`, params);

// 立即支付
export const payNow = params => request.post(`${host}/wechat/order/pay/${params.id}`);

// 取消订单
export const cancelOrder = params => request.post(`${host}/wechat/order/close/${params.id}`);

// 删除订单 /wechat/order/{id}
export const deleteOrder = params => request.delete(`${host}/wechat/order/${params.id}`);

// 确认收货 /wechat/order/confirm/{id}
export const confirmReceive = params => request.put(`${host}/wechat/order/confirm/${params.id}`);

/** 理财师 */
/** 我的客户 */
export const myCustomer = (params) => request.get(`${host}/wechat/real/myCustomer`, params);
/** 新增客户 */
export const realAdd = params => request.post(`${host}/wechat/real/add`, params);
/** 客户详情 */
export const realInfo = id => request.get(`${host}/wechat/real/info/${id}`);
/** 扫小程序二维码 */
export const scanningCode = params => request.get(`${host}/wechat/auth/scanningCode`, params);
/** 我引荐的客户 */
export const myRecommend = (params) => request.get(`${host}/wechat/wechatUser/myRecommend`, params);
// 所有产品分类
export const productClassifyAll = params => request.get(`${host}/wechat/productClassify/list`, params);
/** 我的收藏分页查询(不传查全部) */
export const myCollection = params => request.get(`${host}/wechat/myCollection`, params);

/** ---------------------------- 产品 ---------------------------------- */
/** 所有期限 */
export const allLimit = () => request.get(`${host}/wechat/product/allLimit`);
/** 所有起投 */
export const allStarting = () => request.get(`${host}/wechat/product/allStarting`);
/** 产品分页  */
export const productPages = (params) => request.get(`${host}/wechat/product/pages`, params);
/** 产品详情 */
export const productInfo = (params) => request.get(`${host}/wechat/product/info`, params);
/** 添加收藏 */
export const postCollection = (params) => request.post(`${host}/wechat/myCollection`, params);
/** 取消收藏 */
export const closeCollection = (id) => request.get(`${host}/wechat/myCollection/${id}`);
/** 产品详情 */
export const productContent = (params) => request.get(`${host}/wechat/product/content`, params);
/** 理财师审核通过的客户（选这产品的客户） */
export const myPassCustomer = (params) => request.get(`${host}/wechat/real/myPassCustomer`, params);
/** 理财师电话 */
export const productPhone = (params) => request.get(`${host}/wechat/product/phone`, params);
/** 理财师的客户详情中的产品分页 */
export const functionCustomer = (params) => request.get(`${host}/wechat/productOrder/functionCustomer`, params);
/** 我购买的产品 */
export const productOrderPage = (params) => request.get(`${host}/wechat/productOrder/pages`, params);
/** 理财师帮助客户选择产品分页 */
export const customerPages = (params) => request.get(`${host}/wechat/product/customerPages`, params);
/** 订单详情上传附件 */
export const productOrderUpload = (params) => request.post(`${host}/wechat/productOrder/upload`, params);
/** 产品下单 */
export const productPlanOrder = (params) => request.post(`${host}/wechat/product/planOrder`, params);
/** 产品订单详情 */
export const productOrderInfo = (params) => request.get(`${host}/wechat/productOrder/info`, params);
/** 投资确认书 */
export const posterDetail = (params) => request.get(`${host}/wechat/productOrder/investConfirmation`, params);
/** 题目 */
export const testQuestions = () => request.get(`${host}/wechat/testQuestions`);
/** 答题 */
export const answerQuestions = (params) => request.get(`${host}/wechat/testQuestions/answerQuestions`, params);
/** 用户-积分日志分页 */
export const userIntegralLog = (params) => request.get(`${host}/wechat/userIntegralLog`, params);
/** 获取等级配置 */
export const levelConfig = (params) => request.get(`${host}/wechat/testQuestions/levelConfig`, params);
/** 公众号授权 */

export const wechatToken = (params) => request.get(`${host}/wechat/auth/mp-token`, params);
// /** 分享title */
// export const companyDetail = (params) => request.get(`${host}/wechat/companyDetail`, params);

/** 我的客户 */
export const myCustomerPush = (params) => request.get(`${host}/wechat/real/myCustomerPush`, params);
